import config
import requests
class GoodAPI:
    #初始化
    def __init__(self):
        self.__url_list = config.BASE_URL + "/category/all"
        self.__url_under = config.BASE_URL + "/product/by_category?id={}"
        self.__url = config.BASE_URL + "/product/{}"
    # 获取商品分类
    def get_list(self):
        return requests.get(url=self.__url_list)
    def get_goods_under_list(self,id6):
        return requests.get(url=self.__url_under.format(id6))
    def get_goods_info(self,id8):
        return requests.get(url=self.__url.format(id8))

if __name__ == '__main__':
    print(GoodAPI().get_list().json())
    print(GoodAPI().get_goods_under_list(3).json())
    print(GoodAPI().get_goods_info(7).json())